load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_ruby//ruby:defs.bzl", "ruby_library", "ruby_test")

ruby_library(
    name = "common_tests",
    srcs = ["common_tests.rb"],
)

filegroup(
  name = "test_protos",
  srcs = glob(["*.proto"]),
  visibility = [
      "//ruby:__subpackages__",
  ],
)

ruby_test(
    name = "basic",
    deps = [
        ":common_tests",
        "//ruby:protobuf",
        "//ruby:test_ruby_protos",
        "@protobuf_bundle//:test-unit"
    ],
    srcs = ["basic.rb"],
)

ruby_test(
    name = "basic_proto2",
    deps = [
        ":common_tests",
        "//ruby:protobuf",
        "//ruby:test_ruby_protos",
        "@protobuf_bundle//:test-unit"
    ],
    srcs = ["basic_proto2.rb"],
)

ruby_test(
    name = "encode_decode_test",
    deps = [
        ":common_tests",
        "//ruby:protobuf",
        "//ruby:test_ruby_protos",
        "@protobuf_bundle//:test-unit"
    ],
    srcs = ["encode_decode_test.rb"],
)

ruby_test(
    name = "gc_test",
    deps = [
        ":common_tests",
        "//ruby:protobuf",
        "//ruby:test_ruby_protos",
        "@protobuf_bundle//:test-unit"
    ],
    srcs = ["gc_test.rb"],
)

ruby_test(
    name = "generated_code_test",
    deps = [
        ":common_tests",
        "//ruby:protobuf",
        "//ruby:test_ruby_protos",
        "@protobuf_bundle//:test-unit"
    ],
    srcs = ["generated_code_test.rb"],
)

ruby_test(
    name = "multi_level_nesting_test",
    deps = [
        ":common_tests",
        "//ruby:protobuf",
        "//ruby:test_ruby_protos",
        "@protobuf_bundle//:test-unit"
    ],
    srcs = ["multi_level_nesting_test.rb"],
)

ruby_test(
    name = "repeated_field_test",
    deps = [
        ":common_tests",
        "//ruby:protobuf",
        "//ruby:test_ruby_protos",
        "@protobuf_bundle//:test-unit"
    ],
    srcs = ["repeated_field_test.rb"],
)

ruby_test(
    name = "ruby_version",
    deps = [
        ":common_tests",
        "//ruby:protobuf",
        "//ruby:test_ruby_protos",
        "@protobuf_bundle//:test-unit"
    ],
    srcs = ["ruby_version.rb"],
)

ruby_test(
    name = "stress",
    deps = [
        ":common_tests",
        "//ruby:protobuf",
        "//ruby:test_ruby_protos",
        "@protobuf_bundle//:test-unit"
    ],
    srcs = ["stress.rb"],
)

ruby_test(
    name = "type_errors",
    deps = [
        ":common_tests",
        "//ruby:protobuf",
        "//ruby:test_ruby_protos",
        "@protobuf_bundle//:test-unit"
    ],
    srcs = ["type_errors.rb"],
)

pkg_files(
    name = "dist_files",
    srcs = glob([
        "*.proto",
        "*.rb",
    ]) + [
        "BUILD.bazel",
    ],
    strip_prefix = strip_prefix.from_root(""),
    visibility = ["//ruby:__pkg__"],
)

